<?php

require_once __DIR__ . '/vendor/autoload.php';

use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

$connection = new AMQPStreamConnection('192.168.10.10',5672,'admin','admin');

$channel = $connection ->channel();


$channel ->exchange_declare('log','fanout',false,true,false);

$data = implode(' ', array_slice($argv, 1));
if(empty($data)) $data = "Hello World!";

$msg = new AMQPMessage($data,
    array('delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT)
);

$channel->basic_publish($msg,'log');  

echo " [x] Sent 'Hello World!'\n";
$channel->close();
$connection->close();
